package com.yun.algorithmproblem.leetcode;

public class Leetcode2348 {

    public static void main(String[] args) {
        Leetcode2348 obj = new Leetcode2348();
        int[] nums = new int[]{1, 3, 0, 0, 2, 0, 0, 4};
        System.out.println(obj.zeroFilledSubarray(nums));
    }

    public long zeroFilledSubarray(int[] nums) {
        long ans = 0;
        long currentStreak = 0;
        for (int num : nums) {
            if (num == 0) {
                currentStreak++;
            } else {
                ans += currentStreak * (currentStreak + 1) / 2;
                currentStreak = 0;
            }
        }
        ans += currentStreak * (currentStreak + 1) / 2;
        return ans;
    }
}
